package com.itheima.web.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@Controller
@RestController
@RequestMapping("/json")
public class JsonController {


    @RequestMapping("/test1")
    public void test1(HttpServletResponse response){
         response.setContentType("text/html;charset=utf-8");

        try {
            response.getWriter().write("上海!");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    @RequestMapping(value = "/test2",produces = "text/html;charset=utf-8")
    @ResponseBody
    public String test2(){
        return "海上";
    }
}
